﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using System.Reflection;
using ZeroSum.EntityFrameworkCore.MySql.EntityFrameworks;

namespace ZeroSumDBM.Core.Repositories;

public class ZeroSumDBMDesignTimeDbContextFactory : IDesignTimeDbContextFactory<ZeroSumDbContext>
{
    public ZeroSumDbContext CreateDbContext(string[] args)
    {
        var optionsBuilder = new DbContextOptionsBuilder<ZeroSumDbContext>();
        var serverVersion = new MySqlServerVersion(new Version(8, 0, 25));
        optionsBuilder.UseMySql(
            @"Server = localhost; Port = 3306; Database = ZeroSumDBM; User ID = root; Password = Team163; Charset = utf8mb4; ",
            serverVersion, b => b.MigrationsAssembly(Assembly.GetExecutingAssembly().GetName().Name));

        return new ZeroSumDbContext(optionsBuilder.Options);
    }
}